package com.shujia.day18;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class Home1 {
    public static void main(String[] args) throws IOException {

//        byte[] bytes = new byte[10];
        byte[] bytes = "hell0".getBytes();

        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
        int read = 0;
        while ((read = byteArrayInputStream.read())!= -1){
            System.out.println((char) read);
        }
        byteArrayInputStream.close();


        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        byteArrayOutputStream.write(bytes,0,bytes.length);

        FileOutputStream fileOutputStream = new FileOutputStream("data/byte.txt");
        byteArrayOutputStream.writeTo(fileOutputStream);
        fileOutputStream.close();
        byteArrayOutputStream.close();


    }
}
